package com.woniuxy.member.app.apiImpl;

import cn.hutool.core.bean.BeanUtil;
import com.woniuxy.cloud.mall95.log.Log;
import com.woniuxy.member.app.apiImpl.util.RequestUtil;
import com.woniuxy.member.client.MemberResevationManageClient;
import com.woniuxy.member.client.param.AddReservationParam;
import com.woniuxy.reservation.client.param.InsertReservationParam;
import com.woniuxy.reservation.client.param.InsertTakeNumParam;
import com.woniuxy.reservation.client.reservationclient.ReservationManageClient;
import com.woniuxy.reservation.client.takenumclient.TakeNumManageClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import result.Result;

import javax.validation.Valid;

@RequestMapping("/member")
@RestController
public class MemberResevationManageApiImpl implements MemberResevationManageClient {
    @Autowired
    private ReservationManageClient reservationManageClient;
    @Autowired
    private TakeNumManageClient takeNumManageClient;

    @Log("添加预约")
    @Override
    public Result addQueueNumber(@Valid AddReservationParam addReservationParam) {
        InsertReservationParam insertReservationParam = BeanUtil.toBean(addReservationParam, InsertReservationParam.class);
        insertReservationParam.setStoreId(RequestUtil.getStoreId());
        insertReservationParam.setMemberId(RequestUtil.getMemberId());
        System.out.println(insertReservationParam);
        Result result = reservationManageClient.insertReservation(insertReservationParam);
        return result;
    }
    @Log("取消预约")
    @Override
    public Result deleteReservation(Integer reservationId) {
        Result result = reservationManageClient.deleteReservation(RequestUtil.getStoreId(), reservationId);
        return result;
    }
    @Log("添加排队")
    @Override
    public Result addTakeNum(Integer tableTypeId) {
        InsertTakeNumParam insertTakeNumParam = new InsertTakeNumParam();
        insertTakeNumParam.setMemberId(RequestUtil.getMemberId());
        insertTakeNumParam.setStoreId(RequestUtil.getStoreId());
        insertTakeNumParam.setTableTypeId(tableTypeId);
        Result result = takeNumManageClient.insertTakeNum(insertTakeNumParam);
        return result;
    }


}
